<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <base href="<%=request.getContextPath()%>/"/>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="js/jquery.min.js"></script>
    <!-- Bootstrap Core JavaScript -->
    <script src="js/bootstrap.js"></script>
    <link href="css/bootstrap.css" rel="stylesheet">
    <title>商场收银软件</title>
</head>
<body>
<div class="container" style="width: 100%;">
    <div class="row clearfix">
        <div class="col-md-12 column">
            <table class="table table-striped table-hover table-condensed">
                <thead>
                <tr>
                    <th>编号</th>
                    <th>产品</th>
                    <th>单价 </th>
                    <th>购买数量</th>
                </tr>
                </thead>
                <tbody>
                <c:forEach items="${list}" var="l">
                <tr>
                    <td>${l.id}</td>
                    <td>${l.proName}</td>
                    <td>${l.proPrice}</td>
                    <td><input class="num" type ="number" value="0"/></td>
                </tr>
                </c:forEach>
                </tbody>
            </table>
            <div class="row clearfix">
                <select id="type">
                    <option value="1" selected>正常收费</option>
                    <option value="2" >打折收费</option>
                    <option value="3" >满减收费</option>
                </select>
                <button type="button" id="submit" class="btn btn-primary btn-default">提交</button>
                总计:<input type="text" id="count" disabled/>
            </div>
        </div>
    </div>
</body>
</html>
<script>
    $("#submit").click(function () {
        var aa=$(".num");
        var b="";
        for(let i = 0 ; i<aa.length;i++){
            console.log(aa.eq(i).val());
            if (i<aa.length-1){
                b+=aa.eq(i).val()+","
            }else{
                b+=aa.eq(i).val();
            }
        }
        console.log(b);
        $.post("two/produce/count",{
            numList:b,
            type:$("#type").val()
        },function (data) {
            if(data.success){
                $("#count").val(data.data)
            }
        })
    })
</script>